/*
 * @Autor: dingxiaolin
 * @Date: 2021-06-02 13:12:42
 * @LastEditors: dingxiaolin
 * @LastEditTime: 2021-06-08 11:12:34
 */
import router from '@/router'
import store from '@/store'
import { Modal, message as Message } from 'ant-design-vue'

export function checkCode(code: number, msg: string): void {
    switch (code) {
        case 401: case 403:
            Message.error(msg)
            store.dispatch('user/logout').then((res) => {
                router
                    .replace({
                        name: 'login',
                        query: {
                            redirect: router.currentRoute.value.fullPath
                        }
                    })
                    .finally(() => location.reload())
            })
            break
        default:
            Message.error(msg)

    }
}
